//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.UIDesigner.Monitor
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections.ObjectModel;
    using System.ComponentModel;

    [Serializable]
    public class MonitorSettings : INotifyPropertyChanged, ICloneable
    {
        /// <summary>
        /// A flag to specify whether monitoring has to be enabled.
        /// </summary>
        private bool enableMonitoring = true;

        /// <summary>
        /// A flag to specify whether logging has to be enabled.
        /// </summary>
        private bool enableLogging;

        /// <summary>
        /// Represents the log file path.
        /// </summary>
        private string logFilePath;

        /// <summary>
        /// Flag to specify whether workflow events are to be notified.
        /// </summary>
        private bool notifyWorkflowEvents = true;

        /// <summary>
        /// Flag to specify whether activity events are to be notified.
        /// </summary>
        private bool notifyActivityEvents = true;

        /// <summary>
        /// Flag to specify whether workflow events are to be notified.
        /// </summary>
        private bool notifyTridentEvents = true;

        /// <summary>
        /// Flag to specify whether user events are to be notified.
        /// </summary>
        private bool notifyUserEvents;

        /// <summary>
        /// Flag to specify if errors are to be notified.
        /// </summary>
        private bool levelError;

        /// <summary>
        /// Flag to specify if warnings are to be notified.
        /// </summary>
        private bool levelWarning;

        /// <summary>
        /// Flag to specify if the no info is supposed to be reported.
        /// </summary>
        private bool levelInformation;

        /// <summary>
        /// Flag to specify if the all info is supposed to be reported.
        /// </summary>
        private bool levelAll = true;

        /// <summary>
        /// Raised whenever property is changed
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// A flag to specify whether monitoring has to be enabled.
        /// </summary>
        public bool EnableMonitoring
        {
            get { return enableMonitoring; }
            set
            {
                if (this.enableMonitoring != value)
                {
                    enableMonitoring = value;
                    OnPropertyChanged("EnableMonitoring");
                }
            }
        }

        /// <summary>
        /// A flag to specify whether logging has to be enabled.
        /// </summary>
        public bool EnableLogging
        {
            get { return enableLogging; }
            set
            {
                if (this.enableLogging != value)
                {
                    enableLogging = value;
                    OnPropertyChanged("EnableLogging");
                }
            }
        }

        /// <summary>
        /// Represents the log file path.
        /// </summary>
        public string LogFilePath
        {
            get { return logFilePath; }
            set
            {
                if (this.logFilePath != value)
                {
                    logFilePath = value;
                    OnPropertyChanged("LogFilePath");
                }
            }
        }

        /// <summary>
        /// Flag to specify whether workflow events are to be notified.
        /// </summary>
        public bool NotifyWorkflowEvents
        {
            get { return notifyWorkflowEvents; }
            set
            {
                if (this.notifyWorkflowEvents != value)
                {
                    notifyWorkflowEvents = value;
                    OnPropertyChanged("NotifyWorkflowEvents");
                }
            }
        }

        public bool NotifyActivityEvents
        {
            get { return notifyActivityEvents; }
            set
            {
                if (this.notifyActivityEvents != value)
                {
                    notifyActivityEvents = value;
                    OnPropertyChanged("NotifyActivityEvents");
                }
            }
        }

        /// <summary>
        /// Flag to specify whether workflow events are to be notified.
        /// </summary>
        public bool NotifyTridentEvents
        {
            get { return notifyTridentEvents; }
            set
            {
                if (this.notifyTridentEvents != value)
                {
                    notifyTridentEvents = value;
                    OnPropertyChanged("NotifyTridentEvents");
                }
            }
        }

        /// <summary>
        /// Flag to specify whether user events are to be notified.
        /// </summary>
        public bool NotifyUserEvents
        {
            get { return notifyUserEvents; }
            set
            {
                if (this.notifyUserEvents != value)
                {
                    notifyUserEvents = value;
                    OnPropertyChanged("NotifyUserEvents");
                }
            }
        }

        /// <summary>
        /// Flag to specify if errors are to be notified.
        /// </summary>
        public bool LevelError
        {
            get { return levelError; }
            set
            {
                if (this.levelError != value)
                {
                    levelError = value;
                    OnPropertyChanged("LevelError");
                }
            }
        }

        /// <summary>
        /// Flag to specify if warnings are to be notified.
        /// </summary>
        public bool LevelWarning
        {
            get
            {
                return levelWarning;
            }
            set
            {
                if (this.levelWarning != value)
                {
                    levelWarning = value;
                    OnPropertyChanged("LevelWarning");
                }
            }
        }

        /// <summary>
        /// Flag to specify if the no info is supposed to be reported.
        /// </summary>
        public bool LevelInformation
        {
            get { return levelInformation; }
            set
            {
                if (this.levelInformation != value)
                {
                    levelInformation = value;
                    OnPropertyChanged("LevelInformation");
                }
            }
        }

        /// <summary>
        /// Flag to specify if the all info is supposed to be reported.
        /// </summary>
        public bool LevelAll
        {
            get { return levelAll; }
            set
            {
                if (this.levelAll != value)
                {
                    levelAll = value;
                    OnPropertyChanged("LevelAll");
                }
            }
        }

        /// <summary>
        /// Raises the property changed event.
        /// </summary>
        /// <param name="name">name of the property.</param>
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }

        #region ICloneable Members

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            return MemberwiseClone();
        }

        #endregion
    }
}
